package com.loop.unclelend.ui.adapter

import android.graphics.Color
import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.R
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/12 10:43
 * @Annotation：流程 - Ocr 适配器
 */
class Adapter_Step_Ocr_Type(recyclerView: RecyclerView?) : UncleRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.uncle_item_step_ocr_type) {

    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.layout_item)
    }

    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        val itemLayout = helper.getView<LinearLayout>(R.id.layout_item)
        val imgOcrType = helper.getImageView(R.id.img_ocr_type)
        imgOcrType.setImageResource(model.optInt("imgRes"))
        val textOcrType = helper.getTextView(R.id.txt_ocr_type)
        textOcrType.text = model.optString("ocrTitle")
        val imgOcrSelect = helper.getImageView(R.id.img_ocr_select)

        val isSelect = model.optBoolean("isSelect",false)
        when (isSelect){
            true -> {
                itemLayout.setBackgroundColor(Color.parseColor("#FFFFFFFF"))
                imgOcrSelect.setImageResource(R.mipmap.icon_step_ocr_select)
                textOcrType.setTextColor(Color.parseColor("#FF191919"))
            }
            else -> {
                itemLayout.setBackgroundColor(Color.parseColor("#FFF2F0F5"))
                imgOcrSelect.setImageResource(R.mipmap.icon_step_ocr_normal)
                textOcrType.setTextColor(Color.parseColor("#FF747378"))
            }
        }
    }
}